<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/06/02
// +----------------------------------------------------------------------

namespace app\erp\validate;

use think\Validate;

/**
 * 公共类 验证器 供应商管理
 * @package app\admin\validate
 * @author dou<51779987@qq.com>
 */
class Supplier extends Validate
{
    protected $rule = [
        // 'user_id'	        =>  'require|number',
        'id'		        =>  'require|number|gt:0',
		'title'		        =>  'require|unique:erp_supplier,title^id',
        'code'		        =>  'require|unique:erp_supplier,code^id',
		// 'settlement_cycle'	=>  '',
		'corporate_name'	=>  'require',
		'corporate_address'	=>  'require',
		//'remarks'	        =>  'require',
		'sort' 		        =>  'require|number',
		'supplier_type' 	=>  'require|number',
		'tax_rate' 		    =>  'require',
		'bank_account' 		=>  'require',
		'tax_code' 		    =>  'require',
    ];

    protected $message  =   [
        'user_id' 		    => 'user_id格式错误',
        'id' 			    => 'id格式错误',
        'title.require' 	=> '供应商名称不能为空',
        'title.unique' 	    => '供应商名称已存在',
        'code.require'		=> '供应商编码格式错误',
        'code.unique'		=> '供应商编码已存在',
        'settlement_cycle' 	=> '结算周日（天）不能为空',
        'corporate_name' 	=> '公司名称不能为空',
        'corporate_address' => '公司地址不能为空',
        //'remarks' 	        => '备注不能为空',
        'sort'		        => '排序格式错误',
        'supplier_type'		=> '经营方式格式错误',
        'tax_rate'		    => '税率格式错误',
        'bank_account'		=> '银行账户不能为空',
        'tax_code'		    => '税号不能为空',
    ];

    //验证场景
    protected $scene = [
        'supplier_index'=>  [//列表
            'user_id',
        ],
        'supplier_add'=>  [//添加
            'user_id',
            'title',
            'settlement_cycle',
            'corporate_name',
            'corporate_address',
            //'remarks',
            'sort',
            'supplier_type',
            'tax_rate',
            'bank_account',
            'tax_code',
        ],
        'supplier_edit'=>  [//修改
            'user_id',
            'id',
            'title',
            'settlement_cycle',
            'corporate_name',
            'corporate_address',
            //'remarks',
            'sort',
			'supplier_type',
            'tax_rate',
            'bank_account',
            'tax_code',
        ],
        'supplier_delete'=>  [//删除
            'user_id',
            'id',
        ]
    ];
}
